<!DOCTYPE HTML>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <script src="../../static/js/jquery-3.5.1.min.js" th:src="@{/js/jquery-3.5.1.min.js}"></script>
    <link rel="stylesheet" type="text/css" href="../../static/h-ui/css/H-ui.min.css" th:href="@{/h-ui/css/H-ui.min.css}"/>
    <link rel="stylesheet" type="text/css" href="../../static/h-ui.admin/css/H-ui.admin.css" th:href="@{/h-ui.admin/css/H-ui.admin.css}"/>
    <link rel="stylesheet" type="text/css" href="../../static/lib/Hui-iconfont/1.0.8/iconfont.css" th:href="@{/lib/Hui-iconfont/1.0.8/iconfont.css}"/>
    <link rel="stylesheet" type="text/css" href="../../static/h-ui.admin/skin/default/skin.css" id="skin" th:href="@{/h-ui.admin/skin/default/skin.css}"/>
    <link rel="stylesheet" type="text/css" href="../../static/h-ui.admin/css/style.css" th:href="@{/h-ui.admin/css/style.css}"/>
    <link rel="stylesheet" href="../../static/Semantic-UI-master/dist/semantic.min.css" th:href="@{/Semantic-UI-master/dist/semantic.min.css}">
    <link rel="stylesheet" href="../../static/css/custom.css" th:href="@{/css/custom.css}">
    <title>课程相关作业显示</title>
</head>
<script type="text/javascript" th:inline="javascript">
    $(function () {
        if(![[${session.admin}]]){
            alert("请先去登录")
            window.location.replace("/sy/syadmin/admin")
        }
    })

</script>
<body>
<nav class="breadcrumb"><a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="text-c m-padded-t-middle">
    <div class="" style="padding-bottom: 10px">
        <input class="searchinput1 prompt" type="text" id="searchinput" placeholder="按作业批次搜索......">
        <button class="searchbutton1 ui teal button" id="searchbutton"><i class="search icon"></i></button>
    </div>
</div>
<div class="cl pd-5 bg-1 bk-gray mt-20">
        <span class="l">
			<a class="btn btn-primary radius" th:href="@{/sy/homework/appendhomework(courseid=${session.couseidOfH},useroradmin=0)}"><i class="Hui-iconfont">&#xe600;</i> 去添加练习</a>
		</span>
    <span class="r">共有数据：<strong id="datanum" th:text="${session.courseOfH.size()}"></strong> 条</span> </div>
<div class="mt-20">
    <table class="table table-border table-bordered table-bg table-sort">
        <thead>
        <tr class="text-c">
            <th width="60">作业ID</th>
            <th width="60">课程ID</th>
            <th width="60">题号</th>
            <th width="120">题目</th>
            <th width="60">第几次作业</th>
            <th width="90">A</th>
            <th width="90">B</th>
            <th width="90">C</th>
            <th width="90">D</th>
            <th width="60">正确答案</th>
            <tH width="70">操作</tH>
        </tr>
        </thead>
        <tbody id="searchshow">
        <tr class="text-c" th:each="homework:${session.courseOfH}">
            <td th:text="${homework.hwId}">1</td>
            <td th:text="${homework.courseId}">1</td>
            <td class="text-l" th:text="${homework.hwNum}"></td>
            <td class="text-l" th:text="${homework.hwTitle}">1</td>
            <td class="text-l" th:text="${homework.hwGroup}">1</td>
            <td class="text-l" th:text="${homework.hwCona}">1</td>
            <td class="text-l" th:text="${homework.hwConb}">1</td>
            <td class="text-l" th:text="${homework.hwConc}">1</td>
            <td class="text-l" th:text="${homework.hwCond}">1</td>
            <td th:text="${homework.hwAnswer}">C</td>
            <td class="f-14 product-brand-manage">
                <a style="text-decoration:none" th:onClick="homework_edit('作业编辑','',[[${homework.hwId}]])" href="javascript:;" title="编辑"><i class="Hui-iconfont">&#xe6df;</i></a>
                <a style="text-decoration:none" class="ml-5" th:onClick="homework_del(this,[[${homework.hwId}]])" href="javascript:;" title="删除"><i class="Hui-iconfont">&#xe6e2;</i></a>
            </td>
        </tr>
        </tbody>
    </table>
    <p th:if="${session.courseOfH.size()}==0" class="font-size-middle font-tmd">本课程还没有发布相关的练习......</p>
</div>
</div>
<!--_footer 作为公共模版分离出去-->

<script type="text/javascript" src="../../static/lib/layer/2.4/layer.js" th:src="@{/lib/layer/2.4/layer.js}"></script>
<script type="text/javascript" src="../../static/h-ui/js/H-ui.min.js" th:src="@{/h-ui/js/H-ui.min.js}"></script>
<script type="text/javascript" src="../../static/h-ui.admin/js/H-ui.admin.js" th:src="@{/h-ui.admin/js/H-ui.admin.js}"></script> <!--/_footer 作为公共模版分离出去-->
<script src="../../static/js/jquery-ui.min.js" th:src="@{/js/jquery-ui.min.js}"></script>
<script src="../../static/Semantic-UI-master/dist/semantic.min.js" th:src="@{/Semantic-UI-master/dist/semantic.min.js}"></script>
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="lib/My97DatePicker/4.8/WdatePicker.js" th:src="@{lib/My97DatePicker/4.8/WdatePicker.js}"></script>
<script type="text/javascript" src="lib/datatables/1.10.0/jquery.dataTables.min.js" th:src="@{lib/datatables/1.10.0/jquery.dataTables.min.js}"></script>
<script type="text/javascript" src="lib/laypage/1.2/laypage.js" th:src="@{lib/laypage/1.2/laypage.js}"></script>
<script type="text/javascript">
    /*作业-删除*/
    function homework_del(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            $.ajax({
                type: 'POST',
                url: '/sy/homework/deletehomework',
                cache: false,
                data: {'homeworkId':id},
                success: function(data){
                    $(obj).parents("tr").remove();
                    layer.msg('已删除!',{icon:1,time:1000});
                },
                error:function(data) {
                    layer.msg('出错了',{icon:0,time:1000});
                },
            });
        });
    }


    /*作业-编辑*/
    function homework_edit(title,url,id,w,h){
        $.ajax({
            Type: 'get',
            cache: false,
            url: '/sy/homework/goEditorhomework',
            data: {'homeworkid':id},
            contenType: 'application/json;charset:utf-8',
            success: function(data){
                window.location=data;
            },
            error:function(data) {
                layer.msg('出错了',{icon:0,time:1000});
            },
        })
    }
    //搜索
    $("#searchbutton").click(function () {
        var text = $("#searchinput").val();
        $.ajax({
            type: "get",
            cache: false,
            url: "/sy/homework/search",
            data: {"searchstr":text},
            contenType: "application/json;charset=utf-8",
            success: function (data) {


                if(data.length==0){
                    layer.msg('没有搜索到内容',{icon:0,time:2000});
                }else {
                    $("#datanum").text(data.length);
                    var htmls = '';

                    for(let i=0; i<data.length; i++){
                        var add ='<tr class="text-c">\n' +
                            '            <td>'+data[i].hwId+'</td>\n' +
                            '            <td>'+data[i].courseId+'</td>\n' +
                            '            <td class="text-l">'+data[i].hwNum+'</td>\n' +
                            '            <td class="text-l">'+data[i].hwTitle+'</td>\n' +
                            '            <td class="text-l">'+data[i].hwGroup+'</td>\n' +
                            '            <td class="text-l">'+data[i].hwCona+'</td>\n' +
                            '            <td class="text-l">'+data[i].hwConb+'</td>\n' +
                            '            <td class="text-l">'+data[i].hwConc+'</td>\n' +
                            '            <td class="text-l">'+data[i].hwCond+'</td>\n' +
                            '            <td>'+data[i].hwAnswer+'</td>\n' +
                            '            <td class="f-14 product-brand-manage">\n' +
                            '                <a style="text-decoration:none" onClick="homework_edit(\'作业编辑\',\'\','+data[i].courseId+')" href="javascript:;" title="编辑"><i class="Hui-iconfont">&#xe6df;</i></a>\n' +
                            '                <a style="text-decoration:none" class="ml-5" onClick="homework_del(this,'+data[i].courseId+')" href="javascript:;" title="删除"><i class="Hui-iconfont">&#xe6e2;</i></a>\n' +
                            '            </td>\n' +
                            '        </tr>';


                        htmls += add;
                    }
                    $("#searchshow").html(htmls);
                }
            },
            error: function (message) {
                layer.msg('请根据作业批次搜索',{icon:0,time:1000});
            }
        })

    })
</script>
</body>
</html>